<?php

class Ragtek_Helper_Mail {

    /**
     * Mail sender helper
     * @param <type> $phrase
     * @param <type> $params
     * @param <type> $toEmail
     * @param <type> $toName
     * @param <type> $fromMail
     * @param <type> $fromName
     * @param <type> $languageId
     * @return <type>
     */
    public static function sendMail($phrase, $params, $toEmail = 'admin', $toName = '', $fromMail = '', $fromName = '', $languageId = null) {

        if ($toEmail == 'admin'){
            $toEmail = XenForo_Application::get('options')->defaultEmailAddress;
        }
        
        $mail = new XenForo_Mail($phrase, $params, $languageId);
        $sent = $mail->send($toEmail, $toName, array(), $fromMail, $fromName);

        if (!$sent AND XenForo_Application::debugMode()) {
            // quick and dirty
            die($mail->getFailureException());
        }
        return true;
    }
}